function search(nums: number[], target: number): number {
    let length:number = nums.length,
        l = 0,
        r:number = length,
        mid:number = (l+r)>>1
    while(r>=l){
        mid = (l+r)>>1
        if(nums[mid]===target){
            return mid
        }else if(nums[mid]>target){
            r = mid - 1
        }else {
            l = mid + 1
        }
    }
    return -1
};